import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.key_red = pygame.image.load("../资源/图片/红钥匙.jpg").convert_alpha()
        self.key_yellow = pygame.image.load("../资源/图片/黄钥匙.jpg").convert_alpha()
        self.key_blue = pygame.image.load("../资源/图片/蓝钥匙.jpg").convert_alpha()
        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.door_blue = pygame.image.load("../资源/图片/蓝门.png").convert_alpha()
        self.door_iron = pygame.image.load("../资源/图片/铁门.png").convert_alpha()
        self.door_green = pygame.image.load("../资源/图片/绿门.png").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.hp_red = pygame.image.load("../资源/图片/红药.jpg").convert_alpha()
        self.hp_blue = pygame.image.load("../资源/图片/蓝药.jpg").convert_alpha()
        self.gold_leader = pygame.image.load("../资源/图片/金队长.png").convert_alpha()
        self.gold_soldier = pygame.image.load("../资源/图片/金卫士.png").convert_alpha()
        self.npc_man = pygame.image.load("../资源/图片/老头.png").convert_alpha()
        self.npc_woman = pygame.image.load("../资源/图片/老太.png").convert_alpha()

        self.hero_pos = (0, 1)
        self.up_pos = (0, 10)
        self.down_pos = (0, 0)
        self.variable_pos = {
            (2, 5): (self.door_yellow, '黄门'),
            (2, 7): (self.door_yellow, '黄门'),
            (5, 5): (self.door_yellow, '黄门'),
            (7, 4): (self.door_yellow, '黄门'),
            (8, 5): (self.door_yellow, '黄门'),
            (9, 3): (self.door_yellow, '黄门'),
            (5, 7): (self.door_blue, '蓝门'),
            (7, 7): (self.door_iron, '铁门'),
            (9, 7): (self.door_iron, '铁门'),
            (1, 6): (self.door_green, '绿门'),
            (2, 2): (self.key_yellow, '黄钥匙'),
            (2, 3): (self.key_yellow, '黄钥匙'),
            (4, 2): (self.key_yellow, '黄钥匙'),
            (4, 3): (self.key_yellow, '黄钥匙'),
            (2, 8): (self.key_yellow, '黄钥匙'),
            (2, 9): (self.key_yellow, '黄钥匙'),
            (8, 0): (self.key_yellow, '黄钥匙'),
            (8, 1): (self.key_yellow, '黄钥匙'),
            (8, 2): (self.key_yellow, '黄钥匙'),
            (9, 1): (self.key_blue, '蓝钥匙'),
            (9, 0): (self.key_red, '红钥匙'),
            (2, 1): (self.gem_blue, '蓝宝石'),
            (7, 0): (self.gem_blue, '蓝宝石'),
            (7, 1): (self.gem_blue, '蓝宝石'),
            (7, 2): (self.gem_blue, '蓝宝石'),
            (2, 10): (self.gem_red, '红宝石'),
            (6, 0): (self.gem_red, '红宝石'),
            (6, 1): (self.gem_red, '红宝石'),
            (6, 2): (self.gem_red, '红宝石'),
            (5, 8): (self.hp_red, '红药'),
            (5, 9): (self.hp_red, '红药'),
            (5, 10): (self.hp_red, '红药'),
            (4, 1): (self.hp_blue, '蓝药'),
            (4, 8): (self.hp_blue, '蓝药'),
            (4, 9): (self.hp_blue, '蓝药'),
            (4, 10): (self.hp_blue, '蓝药'),
            (3, 0): (self.gold_leader, '金队长'),
            (9, 2): (self.gold_soldier, '金卫士'),
            (8, 6): (self.gold_soldier, '金卫士'),
            (7, 10): (self.npc_man, '2楼老头'),
            (9, 10): (self.npc_woman, '2楼老太'),
        }

    def fixed_brick(self):
        for i in range(11):
            self.draw(self.wall, 10, i)
            self.dic[(10, i)] = '墙'
        for i in list(range(6))+list(range(7, 11)):
            self.draw(self.wall, 1, i)
            self.dic[(1, i)] = '墙'
        for i in list(range(1, 6))+list(range(7, 11)):
            self.draw(self.wall, 3, i)
            self.dic[(3, i)] = '墙'
        for i in range(4):
            self.draw(self.wall, 5, i)
            self.dic[(5, i)] = '墙'
        for i in range(5, 11):
            self.draw(self.wall, 6, i)
            self.dic[(6, i)] = '墙'
        for i in range(7, 11):
            self.draw(self.wall, 8, i)
            self.dic[(8, i)] = '墙'
        for i in [(4, 5), (4, 7), (7, 5), (9, 5), (6, 3), (7, 3), (8, 3)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
